home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 17 / Hot Mix 17.iso / HM17_SGI / research / lib / test_hp.pro < prev    next >
Text File  |  1997-07-08  |  6KB  |  214 lines

  1. ; $Id: test_hp.pro,v 1.4 1997/01/15 03:11:50 ali Exp $
  2. ;
  3. ; Copyright (c) 1989-1997, Research Systems, Inc.  All rights reserved.
  4. ;       Unauthorized reproduction prohibited.
  5.  
  6. ;+
  7. ; NAME:        TEST_HP
  8. ; PURPOSE:    Generate HP-GL output to test features of the driver.
  9. ; CATEGORY:    Graphics Drivers.
  10. ; CALLING SEQUENCE:
  11. ;    TEST_HP
  12. ; INPUTS:
  13. ;    None.
  14. ; KEYWORD PARAMETERS:
  15. ;    EVASDROP - If this keyword *and* SMART are present, the output
  16. ;        is sent directly to the terminal with an evasdrop configuration
  17. ;        assummed.
  18. ;    SMART - If this keyword is present, it is assummed that the
  19. ;        plotter has a sheet feeder and is able to do
  20. ;        polygon filling. The HP7550A is an example of such
  21. ;        a plotter.
  22. ; OUTPUTS:
  23. ;    If the SMART keyword is present, a file named hpdemo.1 is created
  24. ;    containing 4 pages of plotter output. If SMART and EVASDROP are
  25. ;    present, the output goes to the terminal. Otherwise, three files
  26. ;    named hpdemo.1, hpdemo.2, and hpdemo.3 are created containing
  27. ;    one page of output each.
  28. ; RESTRICTIONS:
  29. ;    Expects the plotter to have 6 pens.
  30. ; SIDE EFFECTS:
  31. ;    Output file(s) are created.
  32. ; MODIFICATION HISTORY:
  33. ;    AB, July, 1989.
  34. ;-
  35.  
  36.  
  37. pro hp_label_page
  38. ; Put a label at (0,0) identifying the page.
  39.  
  40.   common HPDEV,CURPAGE,SMART,EVASDROP
  41.  
  42.   on_error,2                    ;Return to caller if an error occurs
  43.   if (smart) then s = 'HP7550A' else s = 'HP7475'
  44.   xyouts, /norm, 0, -.04, 'HP-GL Demo (' + s + '). Page: ' + $
  45.     strcompress(curpage,/remove_all)
  46.  
  47. end
  48.  
  49.  
  50.  
  51. pro hp_erase
  52. ; Some plotters have a sheet feeder, others can be put offline,
  53. ; and still others (e.g. HP7475) can only handle a page at a time.
  54. ; In order to accomodate the least common denominator, this routine
  55. ; is called to set up the next page. It closes the current file
  56. ; and opens a new one.
  57.  
  58.   common HPDEV,CURPAGE,SMART,EVASDROP
  59.  
  60.   on_error,2                    ;Return to caller if an error occurs
  61.   curpage = curpage + 1
  62.  
  63.   if (EVASDROP or (SMART and (curpage ne 1))) then erase else begin
  64.     DEVICE,/CLOSE
  65.     DEVICE,filename='hpdemo.' + strcompress(curpage,/remove_all)
  66.   endelse
  67.  
  68. end
  69.  
  70.  
  71.  
  72. pro hp_polyfill, title        ; Polygon filling exercise
  73. ;    title - Main title for plot
  74.  
  75. on_error,2                       ;Return to caller if an error occurs
  76. hp_erase
  77. device,/landscape
  78. plot,[0.0, 1.2],[0.0, 1.2],/nodata, title = title
  79. for i = 0.0, 1.1, .2 do oplot, [0, 1.2 - i], [i, 1.2]
  80. for i = 0.2, 1.1, .2 do oplot, [i, 1.2], [0, 1.2 - i]
  81.  
  82. ; Determine the polygon regions
  83. pregion_x = fltarr(5,12)
  84. pregion_y = fltarr(5,12)
  85. pregionlimit = intarr(12) + 4
  86. pregionlimit[0] = 3
  87. pregionlimit[11] = 3
  88. ; zeroth
  89. pregion_x[0:3, 0] = [0.0, 0.2, 0.0, 0.0]
  90. pregion_y[0:3, 0] = [1.0, 1.2, 1.2, 1.0]
  91. ; 11th
  92. pregion_x[0:3, 11] = [1.0, 1.2, 1.2, 1.0]
  93. pregion_y[0:3, 11] = [0.0, 0.0, 0.2, 0.0]
  94. ; 2 - 6
  95. n = 1
  96. for i = 0.2, 1.1, 0.2 do begin
  97.   pregion_x[0:4, n] = [0., i + .2, i, 0., 0.]
  98.   pregion_y[0:4, n] = [1.0-i, 1.2, 1.2, 1.2-i, 1.0-i]
  99.   n = n + 1
  100. endfor
  101. ; 7 - 11
  102. for i = 0.2, 1.1, 0.2 do begin
  103.   pregion_x[0:4, n] = [i, 1.2, 1.2, i-.2, i]
  104.   pregion_y[0:4, n] = [0., 1.2-i, 1.4-i, 0., 0.]
  105.   n = n + 1
  106. endfor
  107.  
  108.  
  109. ; This vector indicates solid vs. line fill polyfilling
  110. fill = intarr(12) + 1
  111. fill[10:11] = 0
  112.  
  113. ; The line attrbiutes if line filling
  114. orient = [ 0.0, 45.0, 90.0, 0.0, 0.0, 45.0, 90.0, 0.0, 22.5, 45.0, 0.0, 0.0 ]
  115. cross = fltarr(12)
  116. cross[7] = [90.0, 112.5, 135.0]
  117. spacing = fltarr(12) + 0.25
  118. spacing[10:11] = 0.0
  119. lstyle = [ 0, 0, 0, 1, 4, 4, 4, 0, 0, 0, 0, 0 ]
  120. color = [2, 3, 4, 5, 6, 2, 3, 4, 5, 6, 2, 3 ]
  121.  
  122. ; Finally, draw the basic styles
  123. for i = 0, 9 do begin
  124.   polyfill, pregion_x[0:pregionlimit[i],i], pregion_y[0:pregionlimit[i],i], $
  125.         line_fill = fill[i], orient=orient[i], spacing=spacing[i], $
  126.         linestyle = lstyle[i], color=color[i]
  127.   if (cross[i] ne 0) then begin
  128.     polyfill, pregion_x[0:pregionlimit[i],i], pregion_y[0:pregionlimit[i],i], $
  129.           line_fill = fill[i], orient=cross[i], spacing=spacing[i], $
  130.           linestyle = lstyle[i], color=color[i]
  131.   endif
  132. endfor
  133. for i = 10,11 do begin
  134.   polyfill, pregion_x[0:pregionlimit[i],i], pregion_y[0:pregionlimit[i],i], $
  135.     color=color[i]
  136. endfor
  137.  
  138. hp_label_page
  139. end
  140.  
  141.  
  142. pro hp_lines_and_color
  143. ; Line styles and color exercise
  144. on_error,2                    ;Return to caller if an error occurs
  145. hp_erase
  146. device,/landscape
  147. a = findgen(100) - 10
  148. plot, sin(a/5)/exp(a/50),/nodata,title='HP-GL Linestyle And Color Test'
  149. for i = 0, 5 do begin
  150.   a = a + 10
  151.   c = i + 1
  152.   y = .4 - .025 * i
  153.   xyouts, /norm, .6, y, strcompress(string(i),/remove_all), color = c
  154.   plots, /norm, [.62, .9], [y, y], color = c, linestyle = i
  155.   oplot, sin(a/5)/exp(a/50), color = c, linestyle=i
  156. endfor
  157. hp_label_page
  158. end
  159.  
  160.  
  161. pro hp_hwtext        ; Hardware Text exercise
  162. on_error,2              ;Return to caller if an error occurs
  163. device,/portrait
  164. hp_erase
  165. !p.font=0
  166. xyouts,/norm,.1,.5,'Hardware Text Demonstration',align=.5,orien=90, $
  167.     color=5, size=2.0
  168. plots,/norm,[.05,.05, .125,.125, .05],[0, 1, 1, 0, 0],color=5
  169.  
  170. plots,/norm,[.5,.5],[0,1]
  171. xyouts,/norm,.5,.7, 'Right Justified Text',align=1.0
  172. xyouts,/norm,.5,.8, 'Centered Text',align=0.5
  173. xyouts,/norm,.2,.3, '2.5 times normal size',size=2.5,orien=30
  174. for i = 1, 4 do begin
  175.   angle = i * 45
  176.   str = '  ' + strcompress(string(angle),/remove_all) + ' degrees rotation'
  177.   xyouts,/norm,.75, .25, str, color=i, orien=angle
  178.   angle = angle + 180
  179.   str = '  ' + strcompress(string(angle),/remove_all) + ' degrees rotation'
  180.   xyouts,/norm,.75, .25, str, color=i, orien=angle
  181. endfor
  182. xyouts,/norm,.5,.9, 'Left Justified Text',align=0.0
  183. !p.font=-1
  184. hp_label_page
  185. end
  186.  
  187.  
  188. pro TEST_HP,SMART=KW_SMART,EVASDROP=KW_EVASDROP
  189.  
  190. common HPDEV,CURPAGE,SMART,EVASDROP
  191. on_error,2                      ;Return to caller if an error occurs
  192. CURPAGE = 0
  193. SMART = (n_elements(KW_SMART) ne 0)
  194. EVASDROP = (n_elements(KW_EVASDROP) ne 0) and SMART
  195.  
  196. current_d = !D.NAME        ; Remember current device
  197. set_plot,'hp'            ; Switch to HP-GL
  198. if (SMART) then DEVICE,/EJECT
  199. if (EVASDROP) then DEVICE,/PLOTTER,file='/dev/tty'
  200.  
  201. hp_lines_and_color
  202. hp_hwtext
  203. hp_polyfill, 'Fill Patterns (Software)'
  204. if (smart) then begin
  205.   DEVICE,/POLYFILL
  206.   hp_polyfill, 'Fill Patterns (Hardware)'
  207. endif
  208.  
  209. set_plot, current_d        ; Return to original device
  210. end
  211.  
  212.  
  213.  
  214.